<?php

class CCodePointArrayString extends CString {
	var $CodePoints;
	
	function Init($codePoints) {
		$this->CodePoints = $codePoints;
	}
	
	function Length() {
		return sizeof($this->CodePoints);
	}
	
	function &Characters($from, $len) {
		$x = new CCodePointArrayIterator($this, $from, $len);
		return $x;
	}
	
	
}

class CCodePointArrayIterator extends CCharIterator {
	var $Str;
	var $CurrentItem;
	var $Remaining;

	function Init($str, $from, $len) {
		$this->Str = $str;
		$this->CurrentItem = $from;
		$this->Remaining = $len;
	}
	
	function NextChar() {
		if ($this->Remaining <= 0)
			return null;
		if ($this->CurrentItem >= sizeof($this->Str->CodePoints))
			return null;
		$c = $this->Str->CodePoints[$this->CurrentItem];
		$this->CurrentItem++;
		$this->Remaining--;
		
		return $c;
	}
}

class CCodePointArrayStringBuilder extends CObject {
	var $CodePointArray = array();
	
	function AppendCharacter($x) {
		$this->CodePointArray[] = $x;
	}
	
	function AppendString($x) {
		$chars = &$x->AllCharacters();
		while (($c = $chars->NextChar()) !== null)
			$this->AppendCharacter($c);
	}
	
	function AsString() {
		return new CCodePointArrayString($this->CodePointArray);
	}
}

?>